{layout name="public/layout" /}
		{include file='yxnavbar'}
{if $op =='display'}
<div class="main">
	<div class="panel panel-info">
		<div class="panel-heading">当前数量： {$total}</div>
	</div>
	<form action="" method="post" onsubmit="return formcheck(this)">
	<div class="panel panel-default">
		<div class="panel-body table-responsive">
			<table class="table table-hover">
				<thead class="navbar-inner">
					<tr>
						<th width="50">ID</th>
						<th>微信</th>
						<th>内容</th>
						<th>启用</th>
						<th>时间</th>
						<th  style="width: 150px; text-align: right;">操作</th>
					</tr>
				</thead>
				<tbody>
					{loop $list $row}
					<tr>
						<td><b>{$row['id']}</b></td>
						<td  style="font-size: 10px;max-width: 100px;">
							<img src="{php echo tomedia($row['avatar']);}" width="28" style="bsection-radius: 3px;">
							<br>
							{$row['nickname']}
						</td>
						<td class="text-left">
							<input type="text" class="form-control" name="content[{$row['id']}][content]}]" value="{$row['content']}"></td>
						<td>
							<input type="checkbox" name="status[]" data-id="{$row['id']}" value="{$row['status']}" class="hidden" {if intval($row['status'])==1} checked="checked" {/if}/>
						</td>
						<td  style="font-size: 10px;max-width: 100px;">{php echo date('Y-m-d H:i', $row['addtime']);}</td>
					 	<td style="text-align:right;">						    
							<a href="{php echo createWebUrl('reply', array('op' => 'delete','themeid'=>$themeid,'replyid'=>$row['id']));}" class="btn btn-warning btn-sm" title="删除" data-toggle="tooltip" data-placement="top" onclick="if(!confirm('删除后将不可恢复，确定删除吗?')) return false;"><i class="fa fa-times"> </i></a>
						</td>
					</tr>
					{/loop}
				</tbody>
			</table>
		</div>
		{$pager}
	</div>
	<div class="form-group col-sm-12">
				<input name="submit" type="submit" class="btn btn-primary col-lg-1" value="更新">
				<input type="hidden" name="__token__" value="{$Request.token}" />
			</div>
	</form>
</div>
<script type="text/javascript">
	$(function(){
		$('.app-preview').click(function(){
			return false;
		});
		require(['underscore', 'bootstrap.switch'], function() {
			$(":checkbox[name='status[]']").bootstrapSwitch();
			$(':checkbox').on('switchChange.bootstrapSwitch', function(e, state){
				$this = $(this);
				var id = $(this).data('id');
				var status = this.checked ? 1 : 0;
				$.post("{php echo createWebUrl('reply', array('op' => 'status','themeid'=>$themeid));}", {status:status, replyid: id}, function(resp){
					resp = $.parseJSON(resp);
					if(resp.message.errno != 0) {
						layer.msg('操作失败, 请稍后重试');
					} else {
						layer.msg('操作成功');
					}
				});
			});
		});
	});
</script>
{else}    
<style>
.table td span{display:inline-block;margin-top:4px;}
.table td input{margin-bottom:0;}
</style>
<div class="clearfix">
<form class="form-horizontal form" action="" method="post" enctype="multipart/form-data">
    <div class="panel panel-default">
        <div class="panel-heading">礼品信息编辑</div>
        <div class="panel-body">
                <input type="hidden" name="goodsid" value="{$goods['id']}">    
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">排序</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="text" class="form-control"  placeholder="例如：1" name="indexno"  value="{$goods['indexno']}">
                    	<span class="help-block">填正整数，数字越小排序越靠前</span>
                    </div>
                </div>        
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"><span style='color:red'>*</span>名称</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="text" class="form-control" placeholder="" name="title" value="{$goods['title']}">
                    	<span class="help-block">礼品名称，字数不宜过多</span>
                    </div>
                </div> 
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">礼品照片</label>
                    <div class="col-sm-8 col-xs-12">
                        {php echo view_form_field_image('img',$goods['img']);}
                    	<span class="help-block">礼品图片，尺寸：287*345</span>
                    </div>
                </div>                
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"><span style='color:red'>*</span>支付价格</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="text" class="form-control" placeholder="" name="fee" value="{$goods['fee']}">
                    	<span class="help-block">实际价格，单位：元</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"><span style='color:red'>*</span>显示价格</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="text" class="form-control" placeholder="" name="price" value="{$goods['price']}">
                    	<span class="help-block">展示价格，单位：元</span>
                    </div>
                </div>
               <div class="form-group">
                	<label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">启用</label>
                	<div class="col-sm-8 col-xs-12">
                    <label class="checkbox">
					  <input type="checkbox" name="status" value="1" {if $goods['status'] == 1}checked="checked"{/if}>勾选则表示启用
					</label>
					 </div>
                </div>                           

                 

        </div>
    </div>
		<div class="form-group">
        <div class="col-sm-12">
            <input name="submit" type="submit" value="提交" class="btn btn-primary col-lg-1">
            <input type="hidden" name="__token__" value="{$Request.token}" />
        </div>
    </div>
</form>
</div>

{/if}
<script type="text/javascript">
    function drop_confirm(msg, url){
        if(confirm(msg)){
            window.location = url;
        }
    }
</script>

